<template>
  <div class="serachList">
    <div class="search-hearch">
      <div class="search-input-nav">
        <n-input 
          class="search-input" 
          placeholder="你在找什么？" 
          size="large" 
          maxlength="200" 
          v-model:value="query.keyWord"
        >
          <template #prefix>
            <i class="iconfont icon-sousuo"></i>
          </template>
        </n-input>
        <!-- 搜索 -->
        <button class="btn" v-if="query.keyWord" @click="searchPush">搜  索</button>
      </div>
      <div class="explain-nav">
        <p>探索</p>
        <p>属于您的家居伴侣</p>
      </div>
    </div>
    <div class="search-list-nav">
      <div class="class-list">
        <div class="class-item" :class="{ select: classSelect === 0 }">
          全部好物
        </div>
        <div 
          class="class-item"
          v-for="(item, i) in productClassData" :key="i"
        >
          {{ item.value }}
        </div>
      </div>
      <div class="product-list">
        <div class="list-title">全部好物</div>
        <div class="list-nav">
          <div 
            class="item-nav"
            v-for="(item, i) in productList" :key="i"
          >
            <!-- {{ item }} -->
            <img class="cover" :src="item.img" />
            <span class="name">{{ item.name }}</span>
            <span class="price">￥{{ item.price }}</span>
          </div>
        </div>
      </div>
    </div>
    <bottomBar />
  </div>
</template>
<script setup>
import { ref, onMounted } from "vue";
import { useRouter } from "vue-router";
import { NInput } from "naive-ui";
import { 
  product_class_data,
  get_product_data
} from "@/appModel/product.model.js";

import BottomBar from "@/components/appBase/bottomBarBase.vue";

const classSelect = ref(0);
const router = useRouter();
const query = ref({ keyWord: "" });

const productClassData = ref(product_class_data);
const productList = ref([]);
const getProductList = () => {
  // console.log("classItemSelect.value => ", classItemSelect.value);
  productList.value = get_product_data({});
};


const searchPush = () => {
  router.push({
    path: "/search",
    query: { keyWord: query.value.keyWord },
  });
};

onMounted(() => {
  getProductList();
});

</script>
<style lang="scss" scoped>
.serachList {
  display: flex;
  flex-direction: column;
  width: 7.5rem;
  height: 100vh;
  margin: 0 auto;
  flex: 1;
  .search-hearch {
    padding: 0.5rem 0.35rem 3rem;
    background: url("https://file.app.ikea.cn/content-hub/f96ef328-1efa-4dd7-befb-0fa4910a9d15/51650998-3b3b-4527-8f3d-0be1a61c75f6.jpeg") center center / 100% auto no-repeat;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    position: relative;
    &::before {
      content: "";
      display: block;
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      background: rgba($color: #000000, $alpha: 0.3);
    }
    .search-input {
      border: 1px solid #fff;
      color: #7047EB;
      font-weight: bolder;
      font-size: 0.23rem;
      .iconfont {
        color: #fff;
      }
      input {
        color: #fff !important;
        font-weight: bolder;
      }
    }
    .search-input-nav {
      position: relative;
      display: flex;
      justify-content: space-between;
      align-items: center;
    }
    .btn {
      position: absolute;
      right: 0.1rem;
      padding: 0 0.2rem;
      font-size: 0.22rem;
      background: none;
      border: none;
      color: #fff;
      border-radius: 0.1rem;
      font-weight: bolder;
    }
    .explain-nav {
      position: absolute;
      margin: 1.4rem 0;
      color: #fff;
      font-weight: bolder;
      font-size: 0.55rem;
      text-shadow: 0.06rem 0.06rem 0.05rem #7047EB;
    }
  }
  .search-list-nav {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    width: 7.5rem;
    position: relative;
    top: -0.2rem;
    border-radius: 0.2rem 0.2rem 0 0;
    background: rgba($color: #0b0d16, $alpha: 1);
    .class-list {
      color: #fff;
      width: 2rem;
      .class-item {
        padding: 0.25rem 0.5rem;
        &.select {
          color: #9876ff;
        }
      }
    }
    .product-list {
      padding: 0.25rem 0;
      width: 5.5rem;
      height: 100%;
      background: rgba($color: #fff, $alpha: 0.05);
      overflow: auto;
      display: flex;
      flex-direction: column;
      justify-content: flex-start;
      align-items: center;
      color: #fff;
      .list-title {
        font-size: 0.25rem;
      }
      .list-nav {
        width: 100%;
        display: flex;
        align-items: center;
        flex-wrap: wrap;
        .item-nav {
          border-radius: 0.15rem;
          margin: 0.025rem;
          padding: 0.3rem 0;
          width: calc(50% - 0.05rem);
          min-height: 4.5rem;
          background: rgba($color: #fff, $alpha: 0.1);
          display: flex;
          flex-direction: column;
          justify-content: flex-start;
          align-items: center;
          position: relative;
          .cover {
            width: 80%;
          }
          .name {
            padding: 0.2rem;
          }
          .price {
            position: absolute;
            bottom: 0.25rem;
            right: 0.25rem;
          }
        }
      }
    }
  }
}
</style>